package com.swgk.core.customview;

import android.content.Context;
import android.content.res.TypedArray;
import android.graphics.Color;
import android.graphics.drawable.Drawable;
import android.text.TextUtils;
import android.util.AttributeSet;
import android.view.LayoutInflater;
import android.view.View;
import android.widget.RelativeLayout;
import android.widget.TextView;

import com.swgk.core.R;

/**
 * @ProjectName :物流详情页复用item
 * @Author : XiongLi
 * @Time :
 */
public class ItemLineTextView extends RelativeLayout {
    private Context context;
    private TextView itemName,itemContent;
    public ItemLineTextView(Context context) {
        this(context, null);
    }

    public ItemLineTextView(Context context, AttributeSet attrs) {
        this(context, attrs, 0);
    }

    public ItemLineTextView(Context context, AttributeSet attrs, int defStyleAttr) {
        super(context, attrs, defStyleAttr);
        this.context= context;
        init();
        setAttrs(attrs);
    }
    private void init() {
        View view = LayoutInflater.from(context).inflate(R.layout.item_type_textview, this);
        itemName = view.findViewById(R.id.item_name);
        itemContent = view.findViewById(R.id.item_content);
    }
    private void setAttrs(AttributeSet attrs){
        if (attrs!=null){
            TypedArray typedArray=context.obtainStyledAttributes(attrs, R.styleable.ItemTypeTextView);
            itemName.setText(typedArray.getString(R.styleable.ItemTypeTextView_item_name));
            itemContent.setText(typedArray.getString(R.styleable.ItemTypeTextView_item_content));
            itemName.setTextColor(typedArray.getColor(R.styleable.ItemTypeTextView_item_name_color, Color.parseColor("#666666")));
            itemContent.setTextColor(typedArray.getColor(R.styleable.ItemTypeTextView_item_content_color,Color.parseColor("#333333")));
            int itemNameSize = (int) typedArray.getDimension(R.styleable.ItemTypeTextView_item_name_size,14);
            itemName.setTextSize(itemNameSize);
            int itemContentSize= (int) typedArray.getDimension(R.styleable.ItemTypeTextView_item_content_size,14);
            itemContent.setTextSize(itemContentSize);
            itemContent.setHint(typedArray.getString(R.styleable.ItemTypeTextView_item_content_hint));
        }
    }
    public void setItemName(String name){
        itemName.setText(name);
    }
    public void setItemContent(String content){
        itemContent.setText(content);
    }
}
